<template>
  <el-scrollbar>
    <div class="top scenetop">
      <div class="buttonclienttext"><span>点击选择数字人模特</span></div>
      <div class="userss">
        <div class="users" v-for="(item, index) in list" :key="item.id">
          <div :class="avttindex === index ? 'userashover' : 'useras'">
            <el-image
              fit="contain"
              @click="userindex(item, index)"
              :src="url + item.static_img"
              ><div slot="placeholder" class="image-slot">
                加载中
                <div class="loader"></div></div
            ></el-image>
            <span class="nametext">{{ item.name }}</span>
          </div>
        </div>
      </div>
    </div>
  </el-scrollbar>
</template>

<script>
import { virtual } from "@/api/virtualhuman";
export default {
  name: "PPTList",
  data() {
    return {
      list: [],
      url: this.$store.getters["url/urls"],
      avttindex: null,
    };
  },
  mounted() {
    this.userlist();
  },
  methods: {
    userindex(val, index) {
      this.avttindex = index;
      this.$emit("userilst", val);
    },
    userlist() {
      //人物列表
      virtual({
        pageIndex: 1,
        pageSize: 100,
        type: 2,
        source: 1,
      }).then((res) => {
        if (res.code === 200) {
          this.list = res.data.list;
        } else {
          this.$message.error(res.msg);
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
html,
body {
  height: 100%;
}

body {
  align-items: center;
  background-color: #1d1f20;
  display: flex;
  justify-content: center;
}

.loader {
  animation: rotate 1s infinite;
  height: 50px;
  width: 50px;
  text-align: center;
  line-height: 50px;
}

.loader:before,
.loader:after {
  border-radius: 50%;
  content: "";
  display: block;
  height: 20px;
  width: 20px;
}
.loader:before {
  animation: ball1 1s infinite;
  background-color: #cb2025;
  box-shadow: 30px 0 0 #f8b334;
  margin-bottom: 10px;
}
.loader:after {
  animation: ball2 1s infinite;
  background-color: #00a096;
  box-shadow: 30px 0 0 #97bf0d;
}

@keyframes rotate {
  0% {
    -webkit-transform: rotate(0deg) scale(0.8);
    -moz-transform: rotate(0deg) scale(0.8);
  }
  50% {
    -webkit-transform: rotate(360deg) scale(1.2);
    -moz-transform: rotate(360deg) scale(1.2);
  }
  100% {
    -webkit-transform: rotate(720deg) scale(0.8);
    -moz-transform: rotate(720deg) scale(0.8);
  }
}

@keyframes ball1 {
  0% {
    box-shadow: 30px 0 0 #f8b334;
  }
  50% {
    box-shadow: 0 0 0 #f8b334;
    margin-bottom: 0;
    -webkit-transform: translate(15px, 15px);
    -moz-transform: translate(15px, 15px);
  }
  100% {
    box-shadow: 30px 0 0 #f8b334;
    margin-bottom: 10px;
  }
}

@keyframes ball2 {
  0% {
    box-shadow: 30px 0 0 #97bf0d;
  }
  50% {
    box-shadow: 0 0 0 #97bf0d;
    margin-top: -20px;
    -webkit-transform: translate(15px, 15px);
    -moz-transform: translate(15px, 15px);
  }
  100% {
    box-shadow: 30px 0 0 #97bf0d;
    margin-top: 0;
  }
}
</style>

<style lang="scss" scoped>
.buttonclienttext {
  color: rgb(168, 168, 168);
  margin-top: 10px;
  font-size: 14px;
}
.userashover {
  box-sizing: border-box;
  border: 2px solid #757575;
  overflow: hidden;
  position: relative;
  border-radius: 10px;
  max-width: 120px;
  max-height: 160px;
  cursor: pointer;
  border: 3px solid #409eff;
}
.useras {
  box-sizing: border-box;
  border: 2px solid #757575;
  overflow: hidden;
  border-radius: 10px;
  max-width: 120px;
  max-height: 160px;
  cursor: pointer;
  &:hover {
    border: 2px solid #409eff;
  }
}
.top {
  box-sizing: border-box;
  background-color: #222;
  width: 100%;
  margin: 0 auto;
  height: 800px;
  box-sizing: border-box;
  padding-bottom: 50px;
  .userss {
    display: flex;
    flex-wrap: wrap;
    .users {
      position: relative;
      max-width: 120px;
      max-height: 160px;
      box-sizing: border-box;
      margin: 2% auto;
      &:hover .useravtar {
        transition-property: all;
        transition-duration: 0.3s;
        transform: scale(1.1);
      }
      .useravtarhover {
        width: 100%;
        height: 100%;
        transition-property: all;
        transition-duration: 0.3s;
        transform: scale(1.1);
      }
    }
  }
  .nametext {
    display: block;
    font-size: 16px;
    border-radius: 5px;
    color: #000;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
    position: absolute;
    bottom: 0px;
  }
}
</style>